home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / fortran / f2c_src.zip / F2C / DEFINES.H < prev    next >
Text File  |  1991-06-10  |  8KB  |  290 lines

  1. #define PDP11 4
  2.  
  3. #define BIGGEST_SHORT    0x7fff        /* Assumes 32-bit arithmetic */
  4. #define BIGGEST_LONG    0x7fffffff    /* Assumes 32-bit arithmetic */
  5.  
  6. #define M(x) (1<<x)    /* Mask (x) returns 2^x */
  7.  
  8. #define ALLOC(x)    (struct x *) ckalloc(sizeof(struct x))
  9. #define ALLEXPR        (expptr) ckalloc( sizeof(union Expression) )
  10. typedef int *ptr;
  11. typedef char *charptr;
  12. typedef FILE *FILEP;
  13. typedef int flag;
  14. typedef char field;    /* actually need only 4 bits */
  15. typedef long int ftnint;
  16. #define LOCAL static
  17.  
  18. #define NO 0
  19. #define YES 1
  20.  
  21. #define CNULL (char *) 0    /* Character string null */
  22. #define PNULL (ptr) 0
  23. #define CHNULL (chainp) 0    /* Chain null */
  24. #define ENULL (expptr) 0
  25.  
  26.  
  27. /* BAD_MEMNO - used to distinguish between long string constants and other
  28.    constants in the table */
  29.  
  30. #define BAD_MEMNO -32768
  31.  
  32.  
  33. /* block tag values -- syntactic stuff */
  34.  
  35. #define TNAME 1
  36. #define TCONST 2
  37. #define TEXPR 3
  38. #define TADDR 4
  39. #define TPRIM 5        /* Primitive datum - should not appear in an
  40.                expptr variable, it should have already been
  41.                identified */
  42. #define TLIST 6
  43. #define TIMPLDO 7
  44. #define TERROR 8
  45.  
  46.  
  47. /* parser states - order is important, since there are several tests for
  48.    state < INDATA   */
  49.  
  50. #define OUTSIDE 0
  51. #define INSIDE 1
  52. #define INDCL 2
  53. #define INDATA 3
  54. #define INEXEC 4
  55.  
  56. /* procedure classes */
  57.  
  58. #define PROCMAIN 1
  59. #define PROCBLOCK 2
  60. #define PROCSUBR 3
  61. #define PROCFUNCT 4
  62.  
  63.  
  64. /* storage classes -- vstg values.  BSS and INIT are used in the later
  65.    merge pass over identifiers; and they are entered differently into the
  66.    symbol table */
  67.  
  68. #define STGUNKNOWN 0
  69. #define STGARG 1    /* adjustable dimensions */
  70. #define STGAUTO 2    /* for stack references */
  71. #define STGBSS 3    /* uninitialized storage (normal variables) */
  72. #define STGINIT 4    /* initialized storage */
  73. #define STGCONST 5
  74. #define STGEXT 6    /* external storage */
  75. #define STGINTR 7    /* intrinsic (late decision) reference.  See
  76.                chapter 5 of the Fortran 77 standard */
  77. #define STGSTFUNCT 8
  78. #define STGCOMMON 9
  79. #define STGEQUIV 10
  80. #define STGREG 11    /* register - the outermost DO loop index will be
  81.                in a register (because the compiler is one
  82.                pass, it can't know where the innermost loop is
  83.                */
  84. #define STGLENG 12
  85. #define STGNULL 13
  86. #define STGMEMNO 14    /* interemediate-file pointer to constant table */
  87.  
  88. /* name classes -- vclass values, also   procclass   values */
  89.  
  90. #define CLUNKNOWN 0
  91. #define CLPARAM 1    /* Parameter - macro definition */
  92. #define CLVAR 2        /* variable */
  93. #define CLENTRY 3
  94. #define CLMAIN 4
  95. #define CLBLOCK 5
  96. #define CLPROC 6
  97. #define CLNAMELIST 7    /* in data with this tag, the   vdcldone   flag should
  98.                be ignored (according to vardcl()) */
  99.  
  100.  
  101. /* vprocclass values -- there is some overlap with the vclass values given
  102.    above */
  103.  
  104. #define PUNKNOWN 0
  105. #define PEXTERNAL 1
  106. #define PINTRINSIC 2
  107. #define PSTFUNCT 3
  108. #define PTHISPROC 4    /* here to allow recursion - further distinction
  109.                is given in the CL tag (those just above).
  110.                This applies to the presence of the name of a
  111.                function used within itself.  The function name
  112.                means either call the function again, or assign
  113.                some value to the storage allocated to the
  114.                function's return value. */
  115.  
  116. /* control stack codes - these are part of a state machine which handles
  117.    the nesting of blocks (i.e. what to do about the ELSE statement) */
  118.  
  119. #define CTLDO 1
  120. #define CTLIF 2
  121. #define CTLELSE 3
  122. #define CTLIFX 4
  123.  
  124.  
  125. /* operators for both Fortran input and C output.  They are common because
  126.    so many are shared between the trees */
  127.  
  128. #define OPPLUS 1
  129. #define OPMINUS 2
  130. #define OPSTAR 3
  131. #define OPSLASH 4
  132. #define OPPOWER 5
  133. #define OPNEG 6
  134. #define OPOR 7
  135. #define OPAND 8
  136. #define OPEQV 9
  137. #define OPNEQV 10
  138. #define OPNOT 11
  139. #define OPCONCAT 12
  140. #define OPLT 13
  141. #define OPEQ 14
  142. #define OPGT 15
  143. #define OPLE 16
  144. #define OPNE 17
  145. #define OPGE 18
  146. #define OPCALL 19
  147. #define OPCCALL 20
  148. #define OPASSIGN 21
  149. #define OPPLUSEQ 22
  150. #define OPSTAREQ 23
  151. #define OPCONV 24
  152. #define OPLSHIFT 25
  153. #define OPMOD 26
  154. #define OPCOMMA 27
  155. #define OPQUEST 28
  156. #define OPCOLON 29
  157. #define OPABS 30
  158. #define OPMIN 31
  159. #define OPMAX 32
  160. #define OPADDR 33
  161. #define OPCOMMA_ARG 34
  162. #define OPBITOR 35
  163. #define OPBITAND 36
  164. #define OPBITXOR 37
  165. #define OPBITNOT 38
  166. #define OPRSHIFT 39
  167. #define OPWHATSIN 40        /* dereferencing operator */
  168. #define OPMINUSEQ 41        /* assignment operators */
  169. #define OPSLASHEQ 42
  170. #define OPMODEQ 43
  171. #define OPLSHIFTEQ 44
  172. #define OPRSHIFTEQ 45
  173. #define OPBITANDEQ 46
  174. #define OPBITXOREQ 47
  175. #define OPBITOREQ 48
  176. #define OPPREINC 49        /* Preincrement (++x) operator */
  177. #define OPPREDEC 50        /* Predecrement (--x) operator */
  178. #define OPDOT 51        /* structure field reference */
  179. #define OPARROW 52        /* structure pointer field reference */
  180. #define OPNEG1 53        /* simple negation under forcedouble */
  181. #define OPDMIN 54        /* min(a,b) macro under forcedouble */
  182. #define OPDMAX 55        /* max(a,b) macro under forcedouble */
  183. #define OPASSIGNI 56        /* assignment for inquire stmt */
  184. #define OPIDENTITY 57        /* for turning TADDR into TEXPR */
  185. #define OPCHARCAST 58        /* for casting to char * (in I/O stmts) */
  186. #define OPDABS 59        /* abs macro under forcedouble */
  187. #define OPMIN2 60        /* min(a,b) macro */
  188. #define OPMAX2 61        /* max(a,b) macro */
  189.  
  190. /* label type codes -- used with the ASSIGN statement */
  191.  
  192. #define LABUNKNOWN 0
  193. #define LABEXEC 1
  194. #define LABFORMAT 2
  195. #define LABOTHER 3
  196.  
  197.  
  198. /* INTRINSIC function codes*/
  199.  
  200. #define INTREND 0
  201. #define INTRCONV 1
  202. #define INTRMIN 2
  203. #define INTRMAX 3
  204. #define INTRGEN 4    /* General intrinsic, e.g. cos v. dcos, zcos, ccos */
  205. #define INTRSPEC 5
  206. #define INTRBOOL 6
  207. #define INTRCNST 7    /* constants, e.g. bigint(1.0) v. bigint (1d0) */
  208.  
  209.  
  210. /* I/O statement codes - these all form Integer Constants, and are always
  211.    reevaluated */
  212.  
  213. #define IOSTDIN ICON(5)
  214. #define IOSTDOUT ICON(6)
  215. #define IOSTDERR ICON(0)
  216.  
  217. #define IOSBAD (-1)
  218. #define IOSPOSITIONAL 0
  219. #define IOSUNIT 1
  220. #define IOSFMT 2
  221.  
  222. #define IOINQUIRE 1
  223. #define IOOPEN 2
  224. #define IOCLOSE 3
  225. #define IOREWIND 4
  226. #define IOBACKSPACE 5
  227. #define IOENDFILE 6
  228. #define IOREAD 7
  229. #define IOWRITE 8
  230.  
  231.  
  232. /* User name tags -- these identify the form of the original identifier
  233.    stored in a   struct Addrblock   structure (in the   user   field). */
  234.  
  235. #define UNAM_UNKNOWN 0        /* Not specified */
  236. #define UNAM_NAME 1        /* Local symbol, store in the hash table */
  237. #define UNAM_IDENT 2        /* Character string not stored elsewhere */
  238. #define UNAM_EXTERN 3        /* External reference; check symbol table
  239.                    using   memno   as index */
  240. #define UNAM_CONST 4        /* Constant value */
  241. #define UNAM_CHARP 5        /* pointer to string */
  242.  
  243.  
  244. #define IDENT_LEN 31        /* Maximum length user.ident */
  245.  
  246. /* type masks - TYLOGICAL defined in   ftypes   */
  247.  
  248. #define MSKLOGICAL    M(TYLOGICAL)
  249. #define MSKADDR    M(TYADDR)
  250. #define MSKCHAR    M(TYCHAR)
  251. #define MSKINT    M(TYSHORT)|M(TYLONG)
  252. #define MSKREAL    M(TYREAL)|M(TYDREAL)    /* DREAL means Double Real */
  253. #define MSKCOMPLEX    M(TYCOMPLEX)|M(TYDCOMPLEX)
  254. #define MSKSTATIC (M(STGINIT)|M(STGBSS)|M(STGCOMMON)|M(STGEQUIV)|M(STGCONST))
  255.  
  256. /* miscellaneous macros */
  257.  
  258. /* ONEOF (x, y) -- x is the number of one of the OR'ed masks in y (i.e., x is
  259.    the log of one of the OR'ed masks in y) */
  260.  
  261. #define ONEOF(x,y) (M(x) & (y))
  262. #define ISCOMPLEX(z) ONEOF(z, MSKCOMPLEX)
  263. #define ISREAL(z) ONEOF(z, MSKREAL)
  264. #define ISNUMERIC(z) ONEOF(z, MSKINT|MSKREAL|MSKCOMPLEX)
  265. #define ISICON(z) (z->tag==TCONST && ISINT(z->constblock.vtype))
  266.  
  267. /* ISCHAR assumes that   z   has some kind of structure, i.e. is not null */
  268.  
  269. #define ISCHAR(z) (z->headblock.vtype==TYCHAR)
  270. #define ISINT(z)   ONEOF(z, MSKINT)    /*   z   is a tag, i.e. a mask number */
  271. #define ISCONST(z) (z->tag==TCONST)
  272. #define ISERROR(z) (z->tag==TERROR)
  273. #define ISPLUSOP(z) (z->tag==TEXPR && z->exprblock.opcode==OPPLUS)
  274. #define ISSTAROP(z) (z->tag==TEXPR && z->exprblock.opcode==OPSTAR)
  275. #define ISONE(z) (ISICON(z) && z->constblock.Const.ci==1)
  276. #define INT(z) ONEOF(z, MSKINT|MSKCHAR)    /* has INT storage in real life */
  277. #define ICON(z) mkintcon( (ftnint)(z) )
  278.  
  279. /* NO66 -- F77 feature is be